/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once

#include <vector>

#include "highfive/H5File.hpp"

#include "DataStructure/Common/Id.h"
#include "DataStructure/Common/Integer.h"
#include "DataStructure/Input/Material/MaterialTypes.h"

#include "DBManager/IRepository/Input/Material/IMaterialSummaryRepository.h"
#include "DBManager/Repository/HDF5/Base/SingleSetRepositoryBase.h"

template <>
inline HighFive::DataType HighFive::create_datatype<SG::DBManager::SummaryInfo<SG::DataStructure::FEM::MaterialTypes>> ()
{
    HighFive::CompoundType compoundType = { { "EID", HighFive::create_datatype<SG::DataStructure::Common::Id> () },
                                            { "TYPE", HighFive::create_datatype<SG::DataStructure::Common::UI8> () },
                                            { "INDEX", HighFive::create_datatype<SG::DataStructure::Common::I64> () } };
    return compoundType;
}
SG_DBMANAGER_HDF5_NAMESPACE_OPEN
class MaterialSummaryRepository : public IMaterialSummaryRepository,
                                  public SingleSetRepositoryBase<SG::DBManager::SummaryInfo<SG::DataStructure::FEM::MaterialTypes>>
{
  public:
    explicit MaterialSummaryRepository (HDF5Database& database);

    void InitialDatasetInfo () override;

    void InitDataset () override;

    /**
     * @brief   : 获取某材料ID的类型
     * @param   : mId
     * @return  :
     * @author  : wxc
     * @date    : 2024.11.06
     */
    std::vector<SG::DataStructure::FEM::MaterialTypes> GetMaterialType (SG::DataStructure::Common::I64 mId) override;

    /**
     * @brief   : 获取本模型中所有材料的类型
     * @return  :
     * @author  : wxc
     * @date    : 2024.11.06
     */
    std::vector<SG::DataStructure::FEM::MaterialTypes> GetAllMaterialType () override;

    /**
     * @brief   : 获取所有材料ID
     * @return  :
     * @author  : wxc
     * @date    : 2024.11.06
     */
    std::vector<SG::DataStructure::Common::Id> GetAllMaterialID () override;
};
SG_DBMANAGER_HDF5_NAMESPACE_CLOSE
